package com.springboot.controller;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.math.BigDecimal;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map;

import com.alibaba.fastjson.JSON;

import org.springframework.web.bind.annotation.*;

import java.util.Calendar;

import java.util.Collections;

import java.util.Date;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import com.springboot.service.OrderzServiceImp;

import com.springboot.entity.Orderz;

import com.springboot.entity.OrderzExample;

import com.springboot.entity.*;
import com.springboot.dao.*;
import com.springboot.entity.User;

import com.springboot.entity.UserExample;

import com.springboot.dao.UserMapper;

import com.springboot.entity.Furniture;

import com.springboot.entity.FurnitureExample;

import com.springboot.dao.FurnitureMapper;

import com.springboot.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.multipart.MultipartFile;

@Controller

@RequestMapping(value = "/")

public class OrderzController {


    private static final Log logger = LogFactory.getLog(OrderzController.class);

    @Autowired
    private OrderzServiceImp orderzservice;


    //定义方法addorderz,响应页面addorderz请求

    @RequestMapping(value = "addorderz")

    public String addorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session) {

        //输出日志，当前执行方法为addorderz

        logger.debug("OrderzController.addorderz ......");

        orderzservice.addorderz(request, session);

        return "addorderz";

    }


    //定义useraddorderz方法

    @RequestMapping(value = "useraddorderz")

    public String useraddorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session) {

        //输出日志，表示当前正在执行OrderzController.useraddorderz方法

        logger.debug("OrderzController.useraddorderz ......");

        orderzservice.useraddorderz(request, session);


        //返回添加订单页面

        return "useraddorderz";

    }


    // 定义userupdateorderz方法

    @RequestMapping(value = "userupdateorderz")

    public String userupdateorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志OrderzController.userupdateorderz

        logger.debug("OrderzController.userupdateorderz ......");

        orderzservice.userupdateorderz(request, session, id);


        // 返回user修改订单页面

        return "userupdateorderz";

    }


    //定义userorderzmanage方法

    @RequestMapping(value = "userorderzmanage")

    public String userorderzmanage(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        //输出日志 ，表示当前正在执行方法为OrderzController.userorderzmanage

        logger.debug("OrderzController.userorderzmanage ......");

        orderzservice.userorderzmanage(request, session); // 返回user订单管理页面


        return "userorderzmanage";

    }


    //定义useraddorderzact，响应页面添加订单请求

    @RequestMapping(value = "useraddorderzact")

    public String useraddorderzact(HttpServletRequest request, HttpSession session, HttpServletResponse response, Orderz orderz) throws IOException {

        //输出日志，表示当前正在执行方法为OrderzController.useraddorderzact

        logger.debug("OrderzController.useraddorderzact ......");

        orderzservice.useraddorderzact(request, session, orderz); //返回到user添加订单方法

        return "forward:/userorderzmanage.action";

    }


    //定义addorderzact方法,将订单信息插入到数据库的t_orderz表中

    @RequestMapping(value = "addorderzact")

    public String addorderzact(HttpServletRequest request, HttpSession session, HttpServletResponse response, Orderz orderz) throws IOException {

        //输出当前方法日志，表示正在执行OrderzController.addorderzact方法

        logger.debug("OrderzController.addorderzact ......");

        orderzservice.addorderzact(request, session, orderz); //返回订单管理方法，执行订单信息的查询

        return "forward:/orderzmanage.action";

    }


    @ResponseBody
    //定义addorderzactjson方法

    @RequestMapping(value = "addorderzactjson")

    public String addorderzactjson(HttpServletRequest request, HttpSession session, HttpServletResponse response, @RequestBody Orderz orderz) throws IOException {

        //输出当前方法日志，表示正在执行OrderzController.addorderzactjson方法

        logger.debug("OrderzController.addorderzactjson ......");


        //调用服务层addorderzact方法

        orderzservice.addorderzactjson(orderz);

        //返回addorderz方法

        return "success";

    }


    //定义orderzmanage方法响应页面请求

    @RequestMapping(value = "orderzmanage")

    public String orderzmanage(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        //输出日志，表示当前正在执行OrderzController.orderzmanage

        logger.debug("OrderzController.orderzmanage ......");


        orderzservice.orderzmanage(request, session); //返回到订单管理页面

        return "orderzmanage";

    }


    // 定义 orderzview方法

    @RequestMapping(value = "orderzview")

    public String orderzview(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        // 输出日志，表示当前正在执行OrderzController.orderzview方法

        logger.debug("OrderzController.orderzview ......");


        orderzservice.orderzview(request, session);

        // 返回订单查看页面

        return "orderzview";

    }


    // 定义 updateorderz方法

    @RequestMapping(value = "updateorderz")

    public String updateorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志OrderzController.updateorderz，表示正在执行该方法

        logger.debug("OrderzController.updateorderz ......");


        orderzservice.updateorderz(request, session, id); // 返回修改订单页面

        return "updateorderz";

    }


    // 定义updateorderzact处理订单修改

    @RequestMapping(value = "updateorderzact")

    public String updateorderzact(HttpServletRequest request, HttpServletResponse response, Orderz orderz, HttpSession session) throws IOException {

        // 输出日志，表示正在执行当前方法OrderzController.updateorderzact

        logger.debug("OrderzController.updateorderzact ......");

        orderzservice.updateorderzact(request, orderz, session);

        // 返回订单管理方法

        return "forward:/orderzmanage.action";

    }

    @ResponseBody
    // 定义updateorderzactjson处理订单修改

    @RequestMapping(value = "updateorderzactjson")

    public String updateorderzactjson(HttpServletRequest request, HttpServletResponse response, @RequestBody Orderz orderz, HttpSession session) throws IOException {

        // 输出日志，表示正在执行当前方法OrderzController.updateorderzactjson

        logger.debug("OrderzController.updateorderzactjson ......");

        orderzservice.updateorderzactjson(orderz);

        return "success";

    }


    // 定义userupdateorderzact方法

    @RequestMapping(value = "userupdateorderzact")

    public String userupdateorderzact(HttpServletRequest request, HttpServletResponse response, Orderz orderz, HttpSession session) throws IOException {

        // 当执行此方法时，输出此日志

        logger.debug("OrderzController.userupdateorderzact ......");

        orderzservice.userupdateorderzact(request, orderz, session);

        // 返回user订单管理方法

        return "forward:/userorderzmanage.action";

    }


    // 定义deleteorderz,处理删除订单

    @RequestMapping(value = "deleteorderz")

    public String deleteorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行OrderzController.deleteorderz方法

        logger.debug("OrderzController.deleteorderz ......");

        orderzservice.deleteorderz(request, session, id);

        // 返回订单管理方法

        return "forward:/orderzmanage.action";

    }


    @ResponseBody
    // 定义deleteorderzjson,处理删除订单

    @RequestMapping(value = "deleteorderzjson")

    public String deleteorderzjson(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行OrderzController.deleteorderz方法

        logger.debug("OrderzController.deleteorderz ......");

        orderzservice.deleteorderz(request, session, id);

        return "success";

    }


    // 定义userdeleteorderz方法

    @RequestMapping(value = "userdeleteorderz")

    public String userdeleteorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行OrderzController.userdeleteorderz方法

        logger.debug("OrderzController.userdeleteorderz ......");


        orderzservice.userdeleteorderz(request, session, id); // 返回user订单管理方法

        return "forward:/userorderzmanage.action";

    }


    // 定义searchorderz方法，处理搜索操作

    @RequestMapping(value = "searchorderz")

    public String searchorderz(HttpServletRequest request, HttpServletResponse response, HttpSession session, String search) {

        // 输出日志，表示当前正在执行OrderzController.searchorderz

        logger.debug("OrderzController.searchorderz ......");


        orderzservice.searchorderz(request, session, search); // 返回查询订单页面

        return "searchorderz";

    }


    @ResponseBody
    // 定义searchorderzjson方法，处理搜索操作
    @RequestMapping(value = "searchorderzjson")

    public Map searchorderzjson(HttpServletRequest request, HttpServletResponse response, HttpSession session, String search) {

        // 输出日志，表示当前正在执行OrderzController.searchorderzjson

        logger.debug("OrderzController.searchorderzjson ......");


        // 定义返回结果

        Map result = new HashMap();

        // 获取返回结果

        result = orderzservice.searchorderzjson(search); // 将结果以json返回

        return result;

    }


    // 定义OrderzpinglunMapper

    @RequestMapping(value = "orderzdetails")

    public String orderzdetails(HttpServletRequest request, HttpSession session, HttpServletResponse response, int id) {

        // 输入日志信息，表名当前执行方法为OrderzController.orderzdetails

        logger.debug("OrderzController.orderzdetails ......");


        orderzservice.orderzdetails(request, session, id); // 返回订单详情页面

        return "orderzdetails";

    }


    @ResponseBody
    // 定义Orderz详情方法

    @RequestMapping(value = "orderzdetailsjson")

    public Map orderzdetailsjson(HttpServletRequest request, HttpSession session, HttpServletResponse response, int id) {

        // 输入日志信息，表名当前执行方法为OrderzController.orderzdetailsjson

        logger.debug("OrderzController.orderzdetailsjson ......");


        Map result = new HashMap();

        result = orderzservice.orderzdetailsjson(id);

        // 将结果以json返回

        return result;

    }


}

